package com.hdwmw.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class SharePreferenceUtil {
	private static String PRE_NAME = "hawmw";
	
	private static String userID = "userID";
	
	private static String username = "username";
	
	public static void setUser(Context context,String userid) {
		SharedPreferences spf = context.getSharedPreferences(PRE_NAME, Context.MODE_PRIVATE);
		Editor editor = spf.edit();
		editor.putString(userID, userid);
		editor.commit();
	}
	
	public static String getUserID(Context context) {
		SharedPreferences spf = context.getSharedPreferences(PRE_NAME, Context.MODE_PRIVATE);
		String mUserID = spf.getString(userID, "");
		return mUserID;
	}
	
	public static void setUserName(Context context,String userName) {
		SharedPreferences spf = context.getSharedPreferences(PRE_NAME, Context.MODE_PRIVATE);
		Editor editor = spf.edit();
		editor.putString(username, userName);
		editor.commit();
	}
	
	public static String getUserName(Context context) {
		SharedPreferences spf = context.getSharedPreferences(PRE_NAME, Context.MODE_PRIVATE);
		String mUserID = spf.getString(username,"");
		return mUserID;
	}
	
	public static void exit(Context context) {
		SharedPreferences spf = context.getSharedPreferences(PRE_NAME, Context.MODE_PRIVATE);
		Editor editor = spf.edit();
		editor.clear();
		editor.commit();
	}
	
}
